package com.buba.controller;


import com.buba.pojo.Dept;
import com.buba.pojo.LgUser;
import com.buba.service.DeptService;
import com.guli.common.ov.R;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author MrJia
 * @since 2020-10-27
 */
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @RequestMapping("selectList/{level}")
    public R selectList(@PathVariable String level) {
        return R.ok().data("deptList", deptService.selectList(level));
    }

    @RequestMapping("selectAll")
    public R selectAll() {
        return R.ok().data("deptList", deptService.list());
    }

    @RequestMapping("insertDept")
    public R insertDept(Dept dept) {
        Boolean aBoolean = deptService.insertDept(dept);
        if (aBoolean) return R.ok().message("successful");
        return R.error().message("error");
    }

    @RequestMapping("showUser")
    public R showUser(LgUser lgUser) {
        return R.ok().data("userList", deptService.showUser(lgUser));
    }

}

